<%--
 *  File:    ApprovalUserGroupForPop.jsp
 *  @Author: Saraxia 
 *  Date:    2012/11/09
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval. 
--%>



<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.ApprovalUserGroupForPop"); 
%>

<% //--------------------------------------  variant and initialization --%>
<%
	String strModuleName = "UPM";
  	String strTableName = "ovinstanceusergroup";
	String privilegeCode = "all";
	String contextPath = request.getContextPath();
%>



<%
  	//get current userinfo
  	HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");
  	Integer nCurOrgId = (Integer)CurUserInfo.get("orgid");
  	String strCurUserName = (String)CurUserInfo.get("username");
  	Integer nCurUserId = (Integer)CurUserInfo.get("userid");
  	String isPrimaryAdmin = (String)CurUserInfo.get("isprimaryadmin");
  	if(isPrimaryAdmin == null)
  	{
    	isPrimaryAdmin = "";
  	} 
  	//give permission
  	boolean bCanUpdatePrimaryAdmin = true;
  	if(!isPrimaryAdmin.equalsIgnoreCase("Y"))
  	{
    	bCanUpdatePrimaryAdmin = false;
  	} 
%>

<% //--------------------------------------  include files list --%>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>


<html>
<head>
<title>ApprovalUserGroupForPop</title>
<PageFlow:CheckPageFlow pageName="instanceusergroupsummary"/>
<%@ include file="/inc/InitEdit.inc" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../../js/FuncLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<%
  	Vector userGroupSummary = (Vector)pageContext.getAttribute("ugsummary");
  	if(userGroupSummary == null)
  	{
    	userGroupSummary = new Vector();
  	}
%>

<script>

function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(usergroupsummaryform,actionvalue,orderbyname);
  //var flag = document.usersummaryform.flag.value;
  //var zylmdapprovalgroupid = document.usersummaryform.zylmdapprovalgroupid.value;
  //editform.action = "ApprovalUserGroupForPop.jsp?<%= OvalTools.randomURL() %>&flag="+flag;
  editform.action = "ApprovalUserGroupForPop.jsp?<%= OvalTools.randomURL() %>&";
  editform.target = "_self";
  isRunning = true;
  editform.submit();  
}

function  closeWindow(){
	
	var zylmdapprovalgroupid = document.getElementById("zylmdapprovalgroupid").value;
	var mdapprovalgroupname = document.getElementById("mdapprovalgroupname").value;
	var isjoint = document.getElementById("isjoint").value;
	//var description = document.usersummaryform.description.value;
	//var isjoint = document.usersummaryform.isjoint.value;
	//var statusname = document.usersummaryform.statusname.value;
	opener.setContact(zylmdapprovalgroupid,mdapprovalgroupname,isjoint);
	window.close();
}


function clickUserGroup(id,mdapprovalgroupname,isjoint)
{
  document.usergroupsummaryform.zylmdapprovalgroupid.value = id;
  document.usergroupsummaryform.mdapprovalgroupname.value = mdapprovalgroupname;
  document.usergroupsummaryform.isjoint.value = isjoint;
}



</script>
<% //--------------------------------------  output variant from pageflow --%>

</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

	<% //--------------------------------------  hidden form variant --%>
	<form name="usergroupsummaryform" method="post" action="../../Dispatcher"  target="_parent">
    <input type="hidden" name="pagename" value="instanceusergroupsummary">
    <input type="hidden" name="actionname">
    <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">
    <custom:hidden property="flag"/>
    
	<% //--------------------------------------  page location --%>
	<%@ include file="/inc/PageLocation.inc" %>
	
	<table width="100%" cellspacing="0" cellpadding="0" border="0">
  	<tr> 
    	<td valign="top"> 
    		<table width="100%" border="0" cellspacing="0">
          	<tr><td class="summary_top" ></td></tr>
        	</table>
        	<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<%@ include file="/inc/SummarySearch.inc" %>
        	</table>
        </td>
   	</tr>
   	</table>
        
        <table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" align="center" width="100%" cellpadding="0">
   
   	<% //--------------------------------------  summary header --%>
   	<tr bgcolor="#ACBCCA"  class="deepblue-left" > 
   		<td width="5%"  class="title_center">&nbsp;</td>
       	<td width="30%" class="title_center"><a href="javascript:page_summary('orderby','mdapprovalgroupname')"><%= label.getLabelName("L_UserGroupName") %></a></td>
       	<td class="30%" class="title_center"><a href="javascript:page_summary('orderby','description')"><%= label.getLabelName("L_description") %></a></td>
       	<td width="20%" class="title_center"><a href="javascript:page_summary('orderby','isjoint')"><%= label.getLabelName("L_YorNExaApproval") %></a></td>
       	<td width="15%" class="title_center"><a href="javascript:page_summary('orderby','statusname')"><%= label.getLabelName("L_Status") %></a></td>
    </tr>

	<% //--------------------------------------  default value definition --%>
    <%
        int i = 0;
        Integer nDefaultzylmdapprovalgroupid = new Integer(-1);               
        String strClassType = new String(); 
        boolean bHasChecked = false;
        String strDefaultIsDisabled="";
        String strDefaultmdapprovalgroupname=""; 
        String strDefaultdescription=""; 
        //String strDefaultisjoint="";
        Integer strDefaultisjoint = new Integer(-1);
        String strDefaultstatusname=""; 
   	%>
        
        <% //--------------------------------------  loop results --%>
        <logic:iterate id="usergroup" collection="<%= userGroupSummary %>" >                     
        <%
    	HashMap userGroupMap = (HashMap)pageContext.getAttribute("usergroup"); 
        String ugName = (String)userGroupMap.get("mdapprovalgroupname");
        String strIsDisabled = "";
        String strIsChecked = "";
            
        if(i%2 == 1)
        {
          	strClassType = "td-listrom";
        }else{                    
          	strClassType = "";
        }
        if(ugName.equalsIgnoreCase("everyone") || ugName.equalsIgnoreCase("administrator"))
        {
        	strIsDisabled = new String(" Disabled ");             
        } 
        else if(!bHasChecked)
        {
	        strIsChecked = "Checked";                       
            bHasChecked = true;
            nDefaultzylmdapprovalgroupid = (Integer)(userGroupMap.get("zylmdapprovalgroupid"));
            strDefaultmdapprovalgroupname= (String)(userGroupMap.get("mdapprovalgroupname"));
            strDefaultdescription= (String)(userGroupMap.get("description"));
            //strDefaultisjoint= (String)(userGroupMap.get("isjoint"));
            strDefaultisjoint = (Integer)(userGroupMap.get("isjoint"));
            strDefaultstatusname= (String)(userGroupMap.get("statusname"));
          	strDefaultIsDisabled = strIsDisabled; 
        } 
        i++;
  	%>
        
	    <tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'" <%if(strIsDisabled.length()==0){%> onClick="javascript:radiotrue('usergroup<%=JspHelper.filterNull( i )%>');clickUserGroup('<%=JspHelper.filterNull( userGroupMap.get("zylmdapprovalgroupid") )%>','<%=JspHelper.filterNull( userGroupMap.get("mdapprovalgroupname") )%>','<%=JspHelper.filterNull( userGroupMap.get("isjoint") )%>');"<%}%> class="<%=JspHelper.filterNull( strClassType )%>">
	    	<td width="5%" class="<%=JspHelper.filterNull( strClassType )%>">
	        	<input id="usergroup<%=JspHelper.filterNull( i )%>" type="radio" name="zylmdapprovalgroupids" <%=JspHelper.filterNull( strIsDisabled )%> value=<%=JspHelper.filterNull( userGroupMap.get("zylmdapprovalgroupid") )%> class="normalradio" <%=JspHelper.filterNull( strIsChecked)%> <%if(strIsDisabled.length()==0){%> onClick="javascript:clickUserGroup('<%=JspHelper.filterNull( userGroupMap.get("zylmdapprovalgroupid") )%>')"<%}%>>
	        </td>
	        <td  class="<%=JspHelper.filterNull( strClassType )%>">&nbsp;<a href="ApprovalUserGroupDetail.jsp?<%= OvalTools.randomURL() %>&zylmdapprovalgroupid=<%=JspHelper.filterNull( userGroupMap.get("zylmdapprovalgroupid") )%>&mdapprovalgroupname=<%=JspHelper.filterNull( userGroupMap.get("mdapprovalgroupname") )%>" target="down"><%=JspHelper.filterNull( userGroupMap.get("mdapprovalgroupname") )%></td>
	        <td class="<%=JspHelper.filterNull( strClassType )%>">&nbsp;<%=JspHelper.filterNull( userGroupMap.get("description") )%></td>
	        <td class="<%=JspHelper.filterNull( strClassType )%>">&nbsp;<custom:write property="isjoint" dictType="YesOrNo" nbsp="true" name="usergroup"  /></td>
	        <td  class="<%=JspHelper.filterNull( strClassType )%>">&nbsp;<%=JspHelper.filterNull( userGroupMap.get("statusname") )%></td>
	    </tr>
        </logic:iterate>                   
        
	    <% //--------------------------------------  default value --%>   
	    <input type="hidden" name="zylmdapprovalgroupid" value="<%=JspHelper.filterNull( nDefaultzylmdapprovalgroupid )%>">
	    <input type="hidden" name="mdapprovalgroupname" value="<%=JspHelper.filterNull( strDefaultmdapprovalgroupname )%>"> 
	    <input type="hidden" name="description" value="<%=JspHelper.filterNull( strDefaultdescription )%>">
	    <input type="hidden" name="isjoint" value="<%=JspHelper.filterNull( strDefaultisjoint )%>">
	    <input type="hidden" name="statusname" value="<%=JspHelper.filterNull( strDefaultstatusname )%>"> 
        <% //--------------------------------------  flipping page --%>
    	<%@ include file="/inc/SummaryAction.inc" %>
          
        </table>
        
        <% //--------------------------------------  page operation button --%>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
        	<tr> 
            	<td class="summary_top" ></td>
          	</tr>
          	<tr> 
            	<td class="td_center">
            		<a onclick="closeWindow()"><custom:button type="1" label="L_Finish" imgsrc="edit.gif" border="0" style="width:60"/></a>
            	</td>
          	</tr>
        </table>
</form>
</body>
</html>

